var url = "../Database/pse?providerName=";

function refreshJson() {
    var json = getJson($("#providerSettings > .propertyInput"));
    $("#providerSettingsJson").val(json);
}

function getJson(elements) {
    var json = "{";
    elements.each(function (i, e) {
        if (i != 0)
            json += ",";
        var type = e.getAttribute("data-value-type");
        var name = e.getAttribute("data-propertyName");
        json += "\"" + name + "\":";
        if (type == "System.String") {
            json += "\"" + $(e).children("input").val().replace("\"", "\\\"") + "\"";
        }
    });
    json += "}";
    return json;
}

$(function () {
    $("#providerName").change(function (e) {
        var u = url + encodeURIComponent($("#providerName").val());
        $.ajax({
            url: u,
            success: function (data) {
                $("#providerSettings").html(data).ready(function () {
                    $("#providerSettings input").change(function (e) {
                        return refreshJson();
                    });
                    refreshJson();
                });
            },
            error: function (e) {
                alert("error loading");
            }
        });
    });
});
//# sourceMappingURL=database-editor.js.map
